﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Data;

namespace Bookvar.UI.Converters
{
    public class DoubleToPercentageConverter : IValueConverter
    {
        public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
        {
            double parsed;
            if ( value!= null && double.TryParse( value.ToString(), out parsed  ) )
            {
                return string.Format( culture, "{0:0%}", parsed );
            }
            return value;
        }

        public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
        {
            throw new NotImplementedException();
        }
    }
}
